home *** CD-ROM | disk | FTP | other *** search
- Path: xanth!cs.odu.edu!Amiga-Request
- From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
- Newsgroups: comp.sources.amiga
- Subject: v90i022: cpp - a c preprocessor with some ANSI features, Part01/05
- Message-ID: <11030@xanth.cs.odu.edu>
- Date: 18 Jan 90 00:17:52 GMT
- Sender: tadguy@cs.odu.edu
- Reply-To: Olaf 'Rhialto' Seibert <U211344@HNYKUN11.BITNET>
- Lines: 1594
- Approved: tadguy@cs.odu.edu (Tad Guy)
-
- Submitted-by: Olaf 'Rhialto' Seibert <U211344@HNYKUN11.BITNET>
- Posting-number: Volume 90, Issue 022
- Archive-name: unix/cpp/part01
-
- - A CPP (the Decus one, from a Fish disk) which has had some ANSI
- features added. Also comes in handy for compiling NetHack 3.0,
- which will be 'final' 'real soon now'.
-
- Freely_Distributable=Greetings(Not_For_Any_Commercial_Purpose)->
- Olaf.Seibert;
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 5)."
- # Contents: Cpp.h cppdef.h makefile org org/contents org/cpp.rno
- # org/make.boot org/makefile.txt org/readme org/readme.txt test.c
- # Wrapped by tadguy@xanth on Wed Jan 17 19:17:31 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Cpp.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Cpp.h'\"
- else
- echo shar: Extracting \"'Cpp.h'\" \(7570 characters\)
- sed "s/^X//" >'Cpp.h' <<'END_OF_FILE'
- X
- X/*
- X * I n t e r n a l D e f i n i t i o n s f o r C P P
- X *
- X * In general, definitions in this file should not be changed.
- X */
- X
- X#ifndef toupper
- X#define toupper(c) ((c) + ('A' - 'a'))
- X#endif /* no toupper */
- X#ifndef tolower
- X#define tolower(c) ((c) + ('a' - 'A'))
- X#endif /* no tolower */
- X
- X#ifndef TRUE
- X#define TRUE 1
- X#define FALSE 0
- X#endif
- X#ifndef EOS
- X/*
- X * This is predefined in Decus C
- X */
- X#define EOS '\0' /* End of string */
- X#endif
- X#define EOF_CHAR 0 /* Returned by get() on eof */
- X#define NULLST ((char *) NULL) /* Pointer to nowhere (linted) */
- X#define DEF_NOARGS (-1) /* #define foo vs #define foo() */
- X
- X/*
- X * The following may need to change if the host system doesn't use ASCII.
- X */
- X#define QUOTE_PARM 0x1C /* Magic quoting operator */
- X#define DEF_MAGIC 0x1D /* Magic for #defines */
- X#define TOK_SEP 0x1E /* Token concatenation delim. */
- X#define COM_SEP 0x1F /* Magic comment separator */
- X
- X/*
- X * Note -- in Ascii, the following will map macro formals onto DEL + the
- X * C1 control character region (decimal 128 .. (128 + PAR_MAC)) which will
- X * be ok as long as PAR_MAC is less than 33). Note that the last PAR_MAC
- X * value is reserved for string substitution.
- X */
- X
- X#define MAC_PARM 0x7F /* Macro formals start here */
- X#if PAR_MAC >= 33
- X assertion fails -- PAR_MAC isn't less than 33
- X#endif
- X#define LASTPARM (PAR_MAC - 1)
- X
- X/*
- X * Character type codes.
- X */
- X
- X#define INV 0 /* Invalid, must be zero */
- X#define OP_EOE INV /* End of expression */
- X#define DIG 1 /* Digit */
- X#define LET 2 /* Identifier start */
- X#define FIRST_BINOP OP_ADD
- X#define OP_ADD 3
- X#define OP_SUB 4
- X#define OP_MUL 5
- X#define OP_DIV 6
- X#define OP_MOD 7
- X#define OP_ASL 8
- X#define OP_ASR 9
- X#define OP_AND 10 /* &, not && */
- X#define OP_OR 11 /* |, not || */
- X#define OP_XOR 12
- X#define OP_EQ 13
- X#define OP_NE 14
- X#define OP_LT 15
- X#define OP_LE 16
- X#define OP_GE 17
- X#define OP_GT 18
- X#define OP_ANA 19 /* && */
- X#define OP_ORO 20 /* || */
- X#define OP_QUE 21 /* ? */
- X#define OP_COL 22 /* : */
- X#define OP_CMA 23 /* , (relevant?) */
- X#define LAST_BINOP OP_CMA /* Last binary operand */
- X/*
- X * The following are unary.
- X */
- X#define FIRST_UNOP OP_PLU /* First Unary operand */
- X#define OP_PLU 24 /* + (draft ANSI standard) */
- X#define OP_NEG 25 /* - */
- X#define OP_COM 26 /* ~ */
- X#define OP_NOT 27 /* ! */
- X#define LAST_UNOP OP_NOT
- X#define OP_LPA 28 /* ( */
- X#define OP_RPA 29 /* ) */
- X#define OP_END 30 /* End of expression marker */
- X#define OP_MAX (OP_END + 1) /* Number of operators */
- X#define OP_FAIL (OP_END + 1) /* For error returns */
- X
- X/*
- X * The following are for lexical scanning only.
- X */
- X
- X#define QUO 65 /* Both flavors of quotation */
- X#define DOT 66 /* . might start a number */
- X#define SPA 67 /* Space and tab */
- X#define BSH 68 /* Just a backslash */
- X#define END 69 /* EOF */
- X
- X/*
- X * These bits are set in ifstack[]
- X */
- X#define WAS_COMPILING 1 /* TRUE if compile set at entry */
- X#define ELSE_SEEN 2 /* TRUE when #else processed */
- X#define TRUE_SEEN 4 /* TRUE when #if TRUE processed */
- X
- X/*
- X * Define bits for the basic types and their adjectives
- X */
- X
- X#define T_CHAR 1
- X#define T_INT 2
- X#define T_FLOAT 4
- X#define T_DOUBLE 8
- X#define T_SHORT 16
- X#define T_LONG 32
- X#define T_SIGNED 64
- X#define T_UNSIGNED 128
- X#define T_PTR 256 /* Pointer */
- X#define T_FPTR 512 /* Pointer to functions */
- X
- X/*
- X * The DEFBUF structure stores information about #defined
- X * macros. Note that the defbuf->repl information is always
- X * in malloc storage.
- X */
- X
- Xtypedef struct defbuf {
- X struct defbuf *link; /* Next define in chain */
- X char *repl; /* -> replacement */
- X int hash; /* Symbol table hash */
- X int nargs; /* For define(args) */
- X char name[1]; /* #define name */
- X} DEFBUF;
- X
- X/*
- X * The FILEINFO structure stores information about open files
- X * and macros being expanded.
- X */
- X
- Xtypedef struct fileinfo {
- X char *bptr; /* Buffer pointer */
- X int line; /* for include or macro */
- X FILE *fp; /* File if non-null */
- X struct fileinfo *parent; /* Link to includer */
- X char *filename; /* File/macro name */
- X char *progname; /* From #line statement */
- X unsigned int unrecur; /* For macro recursion */
- X char buffer[1]; /* current input line */
- X} FILEINFO;
- X
- X/*
- X * The SIZES structure is used to store the values for #if sizeof
- X */
- X
- Xtypedef struct sizes {
- X short bits; /* If this bit is set, */
- X short size; /* this is the datum size value */
- X short psize; /* this is the pointer size */
- X} SIZES;
- X/*
- X * nomacarg is a built-in #define on Decus C.
- X */
- X
- X#ifdef nomacarg
- X#define cput output /* cput concatenates tokens */
- X#else
- X#if COMMENT_INVISIBLE
- X#define cput(c) { if (c != TOK_SEP && c != COM_SEP) putchar(c); }
- X#else
- X#define cput(c) { if (c != TOK_SEP) putchar(c); }
- X#endif
- X#endif
- X
- X#ifndef nomacarg
- X#define streq(s1, s2) (strcmp(s1, s2) == 0)
- X#endif
- X
- X/*
- X * Error codes. VMS uses system definitions.
- X * Decus C codes are defined in stdio.h.
- X * Others are cooked to order.
- X */
- X
- X#if HOST == SYS_VMS
- X#include <ssdef.h>
- X#include <stsdef.h>
- X#define IO_NORMAL (SS$_NORMAL | STS$M_INHIB_MSG)
- X#define IO_ERROR SS$_ABORT
- X#endif
- X/*
- X * Note: IO_NORMAL and IO_ERROR are defined in the Decus C stdio.h file
- X */
- X#ifndef IO_NORMAL
- X#define IO_NORMAL 0
- X#endif
- X#ifndef IO_ERROR
- X#define IO_ERROR 1
- X#endif
- X
- X/*
- X * Externs
- X */
- X
- Xextern int line; /* Current line number */
- Xextern int wrongline; /* Force #line to cc pass 1 */
- Xextern char type[]; /* Character classifier */
- Xextern char *tokenbuf; /* Current input token */
- Xextern int tokenbsize; /* Current size allocated in tokenbuf
- X (not counting 1 byte for zero) */
- Xextern int instring; /* TRUE if scanning string */
- Xextern int inmacro; /* TRUE if scanning #define */
- Xextern int errors; /* Error counter */
- Xextern int recursion; /* Macro depth counter */
- Xextern char ifstack[BLK_NEST]; /* #if information */
- X#define compiling ifstack[0]
- Xextern char *ifptr; /* -> current ifstack item */
- Xextern char *incdir[NINCLUDE]; /* -i directories */
- Xextern char **incend; /* -> active end of incdir */
- Xextern int cflag; /* -C option (keep comments) */
- Xextern int eflag; /* -E option (ignore errors) */
- Xextern int nflag; /* -N option (no pre-defines) */
- Xextern int wflag; /* -W write #defines at end */
- Xextern int rec_recover; /* unwind recursive macros */
- Xextern char *preset[]; /* Standard predefined symbols */
- Xextern char *magic[]; /* Magic predefined symbols */
- Xextern FILEINFO *infile; /* Current input file */
- Xextern char work[NWORK + 1]; /* #define scratch */
- Xextern char *workp; /* Free space in work */
- X#if DEBUG
- Xextern int debug; /* Debug level */
- X#endif
- Xextern int keepcomments; /* Don't remove comments if set */
- Xextern SIZES size_table[]; /* For #if sizeof sizes */
- Xextern char *getmem(); /* Get memory or die. */
- X
- X#ifndef amiga /* Should track usage in cpp6.c */
- Xextern char *incmem(); /* Increase size of block or die. */
- X#endif
- X
- Xextern DEFBUF *lookid(); /* Look for a #define'd thing */
- Xextern DEFBUF *defendel(); /* Symbol table enter/delete */
- Xextern char *savestring(); /* Stuff string in malloc mem. */
- Xextern char *strcpy();
- Xextern char *strncpy();
- Xextern char *strcat();
- Xextern char *strrchr();
- Xextern char *strchr();
- Xextern long time();
- Xextern char *sprintf(); /* Lint needs this */
- Xextern void free ();
- Xextern void exit ();
- END_OF_FILE
- if test 7570 -ne `wc -c <'Cpp.h'`; then
- echo shar: \"'Cpp.h'\" unpacked with wrong size!
- fi
- # end of 'Cpp.h'
- fi
- if test -f 'cppdef.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'cppdef.h'\"
- else
- echo shar: Extracting \"'cppdef.h'\" \(10891 characters\)
- sed "s/^X//" >'cppdef.h' <<'END_OF_FILE'
- X/* Special macro based debugging package */
- X/* Fred Fish, 14-Mar-86 */
- X#ifdef DBUG
- X# include <local/dbug.h>
- X#else
- X# define DBUG_ENTER(a1)
- X# define DBUG_RETURN(a1) return(a1)
- X# define DBUG_VOID_RETURN return
- X# define DBUG_EXECUTE(keyword,a1)
- X# define DBUG_2(keyword,format)
- X# define DBUG_3(keyword,format,a1)
- X# define DBUG_4(keyword,format,a1,a2)
- X# define DBUG_5(keyword,format,a1,a2,a3)
- X# define DBUG_PUSH(a1)
- X# define DBUG_POP()
- X# define DBUG_PROCESS(a1)
- X# define DBUG_FILE (stderr)
- X# define DBUG_SETJMP setjmp
- X# define DBUG_LONGJMP longjmp
- X#endif
- X
- X#ifdef EMACS
- X
- X/* Use the Emacs config file to find out what type of machine */
- X
- X#define NO_SHORTNAMES
- X#include "../src/config.h"
- X
- X/* Convert Emacs's conventions for BIG_ENDIAN to cpp's convention. */
- X#ifdef BIG_ENDIAN
- X#undef BIG_ENDIAN
- X#define BIG_ENDIAN TRUE
- X#else /* not BIG_ENDIAN */
- X#define BIG_ENDIAN FALSE
- X#endif /* BIG_ENDIAN */
- X
- X/* Emacs uses the names index and rindex and defines them as str(r)chr if nec;
- X cpp uses the opposite convention. Here we flush the macro definitions for
- X Emacs and add the ones cpp wants. */
- X
- X#ifdef index
- X#undef index
- X#undef rindex
- X#else /* index is not defined as a macro */
- X#define strchr index
- X#define strrchr rindex
- X#endif /* index is not defined as a macro */
- X
- X#define NBUFF 2048
- X#define NWORK 2048
- X
- X#endif /* EMACS */
- X
- X/*
- X * S y s t e m D e p e n d e n t
- X * D e f i n i t i o n s f o r C P P
- X *
- X * Definitions in this file may be edited to configure CPP for particular
- X * host operating systems and target configurations.
- X *
- X * NOTE: cpp assumes it is compiled by a compiler that supports macros
- X * with arguments. If this is not the case (as for Decus C), #define
- X * nomacarg -- and provide function equivalents for all macros.
- X *
- X * cpp also assumes the host and target implement the Ascii character set.
- X * If this is not the case, you will have to do some editing here and there.
- X */
- X
- X/*
- X * This redundant definition of TRUE and FALSE works around
- X * a limitation of Decus C.
- X */
- X#ifndef TRUE
- X#define TRUE 1
- X#define FALSE 0
- X#endif
- X
- X/*
- X * Define the HOST operating system. This is needed so that
- X * cpp can use appropriate filename conventions.
- X */
- X#define SYS_UNKNOWN 0
- X#define SYS_UNIX 1
- X#define SYS_VMS 2
- X#define SYS_RSX 3
- X#define SYS_RT11 4
- X#define SYS_LATTICE 5
- X#define SYS_ONYX 6
- X#define SYS_68000 7
- X#define SYS_AMIGADOS 8
- X
- X#ifndef HOST
- X#ifdef unix
- X#define HOST SYS_UNIX
- X#else
- X#ifdef vms
- X#define HOST SYS_VMS
- X#else
- X#ifdef rsx
- X#define HOST SYS_RSX
- X#else
- X#ifdef rt11
- X#define HOST SYS_RT11
- X#else
- X#ifdef amiga
- X#define HOST SYS_AMIGADOS
- X#endif
- X#endif
- X#endif
- X#endif
- X#endif
- X#endif
- X
- X#ifndef HOST
- X#define HOST SYS_UNKNOWN
- X#endif
- X
- X/*
- X * We assume that the target is the same as the host system
- X */
- X#ifndef TARGET
- X#define TARGET HOST
- X#endif
- X
- X/*
- X * In order to predefine machine-dependent constants,
- X * several strings are defined here:
- X *
- X * MACHINE defines the target cpu (by name)
- X * SYSTEM defines the target operating system
- X * COMPILER defines the target compiler
- X *
- X * The above may be #defined as "" if they are not wanted.
- X * They should not be #defined as NULL.
- X *
- X * LINE_PREFIX defines the # output line prefix, if not "line"
- X * This should be defined as "" if cpp is to replace
- X * the "standard" C pre-processor.
- X *
- X * FILE_LOCAL marks functions which are referenced only in the
- X * file they reside. Some C compilers allow these
- X * to be marked "static" even though they are referenced
- X * by "extern" statements elsewhere.
- X *
- X * OK_DOLLAR Should be set TRUE if $ is a valid alphabetic character
- X * in identifiers (default), or zero if $ is invalid.
- X * Default is TRUE.
- X *
- X * OK_CONCAT Should be set TRUE if # may be used to concatenate
- X * tokens in macros (per the Ansi Draft Standard) or
- X * FALSE for old-style # processing (needed if cpp is
- X * to process assembler source code).
- X *
- X * OK_DATE Predefines the compilation date if set TRUE.
- X * Not permitted by the Nov. 12, 1984 Draft Standard.
- X *
- X * OK_SIZEOF Permits sizeof in #if preprocessor expressions.
- X * According to K&R V2 (page 232), this is not allowed.
- X *
- X * S_CHAR etc. Define the sizeof the basic TARGET machine word types.
- X * By default, sizes are set to the values for the HOST
- X * computer. If this is inappropriate, see the code in
- X * cpp3.c for details on what to change. Also, if you
- X * have a machine where sizeof (signed int) differs from
- X * sizeof (unsigned int), you will have to edit code and
- X * tables in cpp3.c (and extend the -S option definition.)
- X *
- X * CPP_LIBRARY May be defined if you have a site-specific include directory
- X * which is to be searched *before* the operating-system
- X * specific directories.
- X */
- X
- X#if TARGET == SYS_LATTICE
- X/*
- X * We assume the operating system is pcdos for the IBM-PC.
- X * We also assume the small model (just like the PDP-11)
- X */
- X#define MACHINE "i8086"
- X#define SYSTEM "pcdos"
- X#endif
- X
- X#if TARGET == SYS_ONYX
- X#define MACHINE "z8000"
- X#define SYSTEM "unix"
- X#endif
- X
- X#if TARGET == SYS_VMS
- X#define MACHINE "vax"
- X#define SYSTEM "vms"
- X#define COMPILER "vax11c"
- X#endif
- X
- X#if TARGET == SYS_RSX
- X#define MACHINE "pdp11"
- X#define SYSTEM "rsx"
- X#define COMPILER "decus"
- X#endif
- X
- X#if TARGET == SYS_RT11
- X#define MACHINE "pdp11"
- X#define SYSTEM "rt11"
- X#define COMPILER "decus"
- X#endif
- X
- X#if TARGET == SYS_AMIGADOS
- X#define MACHINE "amiga", "m68000"
- X#define SYSTEM "amigados"
- X#ifdef manx
- X#define COMPILER "manx"
- X#endif
- X#ifdef lattice
- X#define COMPILER "lattice"
- X#endif
- X#ifdef pdc
- X#define COMPILER "pdc", "__PDC__"
- X#endif
- X#endif
- X
- X#if TARGET == SYS_68000
- X/*
- X * All three machine designators have been seen in various systems.
- X * Warning -- compilers differ as to sizeof (int). cpp3 assumes that
- X * sizeof (int) == 2
- X */
- X#define MACHINE "M68000", "m68000", "m68k"
- X#define SYSTEM "unix"
- X#endif
- X
- X#if TARGET == SYS_UNIX
- X#define SYSTEM "unix"
- X#ifdef pdp11
- X#define MACHINE "pdp11"
- X#endif
- X#ifdef vax
- X#define MACHINE "vax"
- X#endif
- X#endif
- X
- X/*
- X * defaults
- X */
- X
- X#ifndef MSG_PREFIX
- X#define MSG_PREFIX "cpp: "
- X#endif
- X
- X#ifndef LINE_PREFIX
- X#ifdef decus
- X#define LINE_PREFIX ""
- X#else
- X#define LINE_PREFIX "line"
- X#endif
- X#endif
- X
- X/*
- X * OLD_PREPROCESSOR forces the definition of OK_DOLLAR, OK_CONCAT,
- X * COMMENT_INVISIBLE, and STRING_FORMAL to values appropriate for
- X * an old-style preprocessor.
- X */
- X
- X#if OLD_PREPROCESSOR
- X#define OK_DOLLAR FALSE
- X#define OK_CONCAT FALSE
- X#define COMMENT_INVISIBLE TRUE
- X#define STRING_FORMAL TRUE
- X#endif
- X
- X/*
- X * RECURSION_LIMIT may be set to -1 to disable the macro recursion test.
- X */
- X#ifndef RECURSION_LIMIT
- X#define RECURSION_LIMIT 1000
- X#endif
- X
- X/*
- X * BITS_CHAR may be defined to set the number of bits per character.
- X * it is needed only for multi-byte character constants.
- X */
- X#ifndef BITS_CHAR
- X#define BITS_CHAR 8
- X#endif
- X
- X/*
- X * BIG_ENDIAN is set TRUE on machines (such as the IBM 360 series)
- X * where 'ab' stores 'a' in the high-bits and 'b' in the low-bits.
- X * It is set FALSE on machines (such as the PDP-11 and Vax-11)
- X * where 'ab' stores 'a' in the low-bits and 'b' in the high-bits.
- X * (Or is it the other way around?) -- Warning: BIG_ENDIAN code is untested.
- X * [I *seems* to be the other way around, according to the code /OIS]
- X */
- X#ifndef BIG_ENDIAN
- X#define BIG_ENDIAN FALSE
- X#endif
- X
- X/*
- X * COMMENT_INVISIBLE may be defined to allow "old-style" comment
- X * processing, whereby the comment becomes a zero-length token
- X * delimiter. This permitted tokens to be concatenated in macro
- X * expansions. This was removed from the Draft Ansi Standard.
- X */
- X#ifndef COMMENT_INVISIBLE
- X#define COMMENT_INVISIBLE FALSE
- X#endif
- X
- X/*
- X * STRING_FORMAL may be defined to allow recognition of macro parameters
- X * anywhere in replacement strings. This was removed from the Draft Ansi
- X * Standard and a limited recognition capability added.
- X */
- X#ifndef STRING_FORMAL
- X#define STRING_FORMAL FALSE
- X#endif
- X
- X/*
- X * OK_DOLLAR enables use of $ as a valid "letter" in identifiers.
- X * This is a permitted extension to the Ansi Standard and is required
- X * for e.g., VMS, RSX-11M, etc. It should be set FALSE if cpp is
- X * used to preprocess assembler source on Unix systems. OLD_PREPROCESSOR
- X * sets OK_DOLLAR FALSE for that reason.
- X */
- X#ifndef OK_DOLLAR
- X#define OK_DOLLAR TRUE
- X#endif
- X
- X/*
- X * OK_CONCAT enables (one possible implementation of) token concatenation.
- X * If cpp is used to preprocess Unix assembler source, this should be
- X * set FALSE as the concatenation character, #, is used by the assembler.
- X */
- X#ifndef OK_CONCAT
- X#define OK_CONCAT TRUE
- X#endif
- X
- X/*
- X * OK_DATE may be enabled to predefine today's date as a string
- X * at the start of each compilation. This is apparently not permitted
- X * by the Draft Ansi Standard.
- X */
- X#ifndef OK_DATE
- X#define OK_DATE TRUE
- X#endif
- X
- X/*
- X * OK_SIZEOF may be defined to allow sizeof(type) in #if expressions.
- X * Actually, it is none of the preprocessors business how large these
- X * things are, as they might be different with different compiler
- X * options. Also, according to K&R V2, page 232, it is nonstandard.
- X * This option was added in the PDC process, under no. *OIS*0.92*.
- X */
- X#ifndef OK_SIZEOF
- X#define OK_SIZEOF FALSE
- X#endif
- X
- X/*
- X * Some common definitions.
- X */
- X
- X#ifndef DEBUG
- X#define DEBUG FALSE
- X#endif
- X
- X/*
- X * The following definitions are used to allocate memory for
- X * work buffers. In general, they should not be modified
- X * by implementors.
- X *
- X * PAR_MAC The maximum number of #define parameters (31 per Standard)
- X * Note: we need another one for strings.
- X * NBUFF Input buffer size
- X * NWORK Work buffer size -- the longest macro
- X * must fit here after expansion.
- X * NEXP The nesting depth of #if expressions
- X * NINCLUDE The number of directories that may be specified
- X * on a per-system basis, or by the -I option.
- X * BLK_NEST The number of nested #if's permitted.
- X */
- X
- X#ifndef PAR_MAC
- X#define PAR_MAC (31 + 1)
- X#endif
- X
- X#ifndef NBUFF
- X#define NBUFF 512
- X#endif
- X
- X#ifndef NWORK
- X#define NWORK 512
- X#endif
- X
- X#ifndef NEXP
- X#define NEXP 128
- X#endif
- X
- X#ifndef NINCLUDE
- X#define NINCLUDE 7
- X#endif
- X
- X#ifndef NPARMWORK
- X#define NPARMWORK (NWORK * 2)
- X#endif
- X
- X#ifndef BLK_NEST
- X#define BLK_NEST 32
- X#endif
- X
- X
- X/*
- X * Some special constants. These may need to be changed if cpp
- X * is ported to a wierd machine.
- X *
- X * NOTE: if cpp is run on a non-ascii machine, ALERT and VT may
- X * need to be changed. They are used to implement the proposed
- X * ANSI standard C control characters '\a' and '\v' only.
- X * DEL is used to tag macro tokens to prevent #define foo foo
- X * from looping. Note that we don't try to prevent more elaborate
- X * #define loops from occurring.
- X */
- X
- X#ifndef ALERT
- X#define ALERT '\007' /* '\a' is "Bell" */
- X#endif
- X
- X#ifndef VT
- X#define VT '\013' /* Vertical Tab CTRL/K */
- X#endif
- X
- X
- X#ifndef FILE_LOCAL
- X#ifdef decus
- X#define FILE_LOCAL static
- X#else
- X#ifdef vax11c
- X#define FILE_LOCAL static
- X#else
- X#define FILE_LOCAL /* Others are global */
- X#endif
- X#endif
- X#endif
- END_OF_FILE
- if test 10891 -ne `wc -c <'cppdef.h'`; then
- echo shar: \"'cppdef.h'\" unpacked with wrong size!
- fi
- # end of 'cppdef.h'
- fi
- if test -f 'makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makefile'\"
- else
- echo shar: Extracting \"'makefile'\" \(4001 characters\)
- sed "s/^X//" >'makefile' <<'END_OF_FILE'
- X# Makefile for cpp
- X#
- X# On certain systems, such as Unix System III, you may need to define
- X# $(LINTFLAGS) in the make command line to set system-specific lint flags.
- X#
- X# This Makefile assumes cpp will replace the "standard" preprocessor.
- X# Delete the reference to -DLINE_PREFIX=\"\" if cpp is used stand-alone.
- X# LINEFIX is a sed script filter that reinserts #line -- used for testing
- X# if LINE_PREFIX is set to "". Note that we must stand on our heads to
- X# match the # and a line had better not begin with $. By the way, what
- X# we really want is
- X# LINEFIX = | sed "s/^#/#line/"
- X#
- X#CPPDEFINE = -DLINE_PREFIX=\"\"
- X#LINEFIX = | sed "s/^[^ !\"%-~]/&line/"
- X#
- X# Define OLD_PREPROCESSOR non-zero to make a preprocessor which is
- X# "as compatible as possible" with the standard Unix V7 or Ultrix
- X# preprocessors. This is needed to rebuild 4.2bsd, for example, as
- X# the preprocessor is used to modify assembler code, rather than C.
- X# This is not recommended for current development. OLD_PREPROCESSOR
- X# forces the following definitions:
- X# OK_DOLLAR FALSE $ is not allowed in variables
- X# OK_CONCAT FALSE # cannot concatenate tokens
- X# COMMENT_INVISIBLE TRUE old-style comment concatenation
- X# STRING_FORMAL TRUE old-style string expansion
- X#
- X# The following kludge bypasses the need for Fred's cc program by
- X# invoking the cpp front end cpp preprocessor. The intermediate file
- X# is stored in ram, pre-appended with an underscore. Manx's cc program
- X# is then invoked on the intermediate file. The amigados delete command
- X# kills the intermediate file.
- X
- X#OLDDEFINE = -DOLD_PREPROCESSOR=1
- XHOST = -Damiga -Dpdc
- XEMACS =
- XDEBUGFLAG =
- XLDFLAGS =
- X#
- X# DEFINES collects all -D arguments for cc and lint:
- X# Change DEFINES = $(CPPDEFINE) $(OLDDEFINE)
- X# for an old-style preprocessor.
- X# If being used for GNU Emacs, the macro EMACS will be defined as -DEMACS.
- X#
- XDEFINES = $(OLDDEFINE) $(EMACS) $(HOST)
- X
- XCC = cc
- X#DEBUGFLAG = -g
- XCFLAGS = $(DEBUGFLAG) $(DEFINES) $(CPPDEFINE)
- XLIBS = -lc32
- X
- X.c.o:
- X OldCpp $(CFLAGS) $*.c ram:_$*.c
- X cc +L -o $*.o ram:_$*.c
- X delete ram:_$*.c
- X
- X# ** compile cpp
- X#
- XSRCS = cpp1.c cpp2.c cpp3.c cpp4.c cpp5.c cpp6.c
- XOBJS = cpp1.o cpp2.o cpp3.o cpp4.o cpp5.o cpp6.o
- X
- Xcpp : $(OBJS)
- X ln -o Cpp $(LDFLAGS) $(OBJS) $(LIBS)
- X
- X#
- X# ** Test cpp by preprocessing itself, compiling the result,
- X# ** repeating the process and diff'ing the result. Note: this
- X# ** is not a good test of cpp, but a simple verification.
- X# ** The diff's should not report any changes.
- X# ** Note that a sed script may be executed for each compile
- X#
- Xtest :
- X cpp cpp1.c $(LINEFIX) >old.tmp1.c
- X cpp cpp2.c $(LINEFIX) >old.tmp2.c
- X cpp cpp3.c $(LINEFIX) >old.tmp3.c
- X cpp cpp4.c $(LINEFIX) >old.tmp4.c
- X cpp cpp5.c $(LINEFIX) >old.tmp5.c
- X cpp cpp6.c $(LINEFIX) >old.tmp6.c
- X $(CC) $(CFLAGS) old.tmp[123456].c
- X a.out cpp1.c >new.tmp1.c
- X a.out cpp2.c >new.tmp2.c
- X a.out cpp3.c >new.tmp3.c
- X a.out cpp4.c >new.tmp4.c
- X a.out cpp5.c >new.tmp5.c
- X a.out cpp6.c >new.tmp6.c
- X diff old.tmp1.c new.tmp1.c
- X diff old.tmp2.c new.tmp2.c
- X diff old.tmp3.c new.tmp3.c
- X diff old.tmp4.c new.tmp4.c
- X diff old.tmp5.c new.tmp5.c
- X diff old.tmp6.c new.tmp6.c
- X rm a.out old.tmp[123456].* new.tmp[123456].*
- X
- X#
- X# A somewhat more extensive test is provided by the "clock"
- X# program (which is not distributed). Substitute your favorite
- X# macro-rich program here.
- X#
- Xclock : clock.c cpp
- X cpp clock.c $(LINEFIX) >temp.cpp.c
- X cc temp.cpp.c -lcurses -ltermcap -o clock
- X rm temp.cpp.c
- X
- X#
- X# ** Lint the code
- X#
- X
- Xlint : $(SRCS)
- X lint $(LINTFLAGS) $(DEFINES) $(SRCS)
- X
- X#
- X# ** Remove unneeded files
- X#
- Xclean :
- X rm -f $(OBJS) cpp
- X
- X#
- X# ** Rebuild the archive files needed to distribute cpp
- X# ** Uses the Decus C archive utility.
- X#
- X
- Xarchc : archc.c
- X $(CC) $(CFLAGS) archc.c -o archc
- X
- Xarchx : archx.c
- X $(CC) $(CFLAGS) archx.c -o archx
- X
- Xarchive : archc
- X archc readme.txt cpp.mem archx.c archc.c cpp.rno makefile.txt \
- X cpp*.h >cpp1.arc
- X archc cpp1.c cpp2.c cpp3.c >cpp2.arc
- X archc cpp4.c cpp5.c cpp6.c >cpp3.arc
- X
- X#
- X# Object module dependencies
- X#
- X
- X$(OBJS) : cpp.h cppdef.h
- END_OF_FILE
- if test 4001 -ne `wc -c <'makefile'`; then
- echo shar: \"'makefile'\" unpacked with wrong size!
- fi
- # end of 'makefile'
- fi
- if test ! -d 'org' ; then
- echo shar: Creating directory \"'org'\"
- mkdir 'org'
- fi
- if test -f 'org/contents' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'org/contents'\"
- else
- echo shar: Extracting \"'org/contents'\" \(107 characters\)
- sed "s/^X//" >'org/contents' <<'END_OF_FILE'
- XAn implementation of cpp (C Preprocessor) as distributed
- Xby DECUS. This version was done by Martin Minow.
- END_OF_FILE
- if test 107 -ne `wc -c <'org/contents'`; then
- echo shar: \"'org/contents'\" unpacked with wrong size!
- fi
- # end of 'org/contents'
- fi
- if test -f 'org/cpp.rno' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'org/cpp.rno'\"
- else
- echo shar: Extracting \"'org/cpp.rno'\" \(8099 characters\)
- sed "s/^X//" >'org/cpp.rno' <<'END_OF_FILE'
- X.lm 8.rm 72.nhy
- X
- X.no autosubtitle .style headers 3,0,0
- X.pg.uc.ps 58,80.lm 8.rm 72
- X.hd
- X.hd mixed
- X.head mixed
- X
- X.st ########cpp#####C Pre-Processor
- X.pg
- X.hl 1 ^&C Pre-Processor\&
- X.s 2
- X.c ;*******
- X.c ;* cpp *
- X.c ;*******
- X.s 2
- X.lm +8
- X.s.i -8;NAME: cpp -- C Pre-Processor
- X.s.f
- X.i -8;SYNOPSIS:
- X.s.nf
- Xcpp [-options] [infile [outfile]]
- X.s.f
- X.i -8;DESCRIPTION:
- X.s
- XCPP reads a C source file, expands macros and include
- Xfiles, and writes an input file for the C compiler.
- XIf no file arguments are given, CPP reads from stdin
- Xand writes to stdout. If one file argument is given,
- Xit will define the input file, while two file arguments
- Xdefine both input and output files. The file name "-"
- Xis a synonym for stdin or stdout as appropriate.
- X.s
- XThe following options are supported. Options may
- Xbe given in either case.
- X.lm +16
- X.p -16
- X-C If set, source-file comments are written
- Xto the output file. This allows the output of CPP to be
- Xused as the input to a program, such as lint, that expects
- Xcommands embedded in specially-formatted comments.
- X.p -16
- X-Dname=value Define the name as if the programmer wrote
- X.s
- X.nf
- X _#define name value
- X.s
- X.fill
- Xat the start of the first file. If "=value" is not
- Xgiven, a value of "1" will be used.
- X.s
- XOn non-unix systems, all alphabetic text will be forced
- Xto upper-case.
- X.p -16
- X-E Always return "success" to the operating
- Xsystem, even if errors were detected. Note that some fatal
- Xerrors, such as a missing _#include file, will terminate
- XCPP, returning "failure" even if the -E option is given.
- X.p -16
- X-Idirectory Add this directory to the list of
- Xdirectories searched for _#include "..." and _#include <...>
- Xcommands. Note that there is no space between the
- X"-I" and the directory string. More than one -I command
- Xis permitted. On non-Unix systems "directory" is forced
- Xto upper-case.
- X.p -16
- X-N CPP normally predefines some symbols defining
- Xthe target computer and operating system. If -N is specified,
- Xno symbols will be predefined. If -N -N is specified, the
- X"always present" symbols, ____LINE____, ____FILE____, and ____DATE____
- Xare not defined.
- X.p -16
- X-Stext CPP normally assumes that the size of
- Xthe target computer's basic variable types is the same as the size
- Xof these types of the host computer. (This can be overridden
- Xwhen CPP is compiled, however.) The -S option allows dynamic
- Xrespecification of these values. "text" is a string of
- Xnumbers, separated by commas, that specifies correct sizes.
- XThe sizes must be specified in the exact order:
- X.s
- X.nf
- X char short int long float double
- X.s
- X.fill
- XIf you specify the option as "-S*text", pointers to these
- Xtypes will be specified. -S* takes one additional argument
- Xfor pointer to function (e.g. int (*)())
- X.s
- XFor example, to specify sizes appropriate for a PDP-11,
- Xyou would write:
- X.s
- X.nf
- X c s i l f d func
- X -S1,2,2,2,4,8,
- X -S*2,2,2,2,2,2,2
- X.s
- X.fill
- XNote that all values must be specified.
- X.p -16
- X-Uname Undefine the name as if
- X.s
- X.nf
- X _#undef name
- X.s
- X.fill
- Xwere given. On non-Unix systems, "name" will be forced to
- Xupper-case.
- X.p -16
- X-Xnumber Enable debugging code. If no value is
- Xgiven, a value of 1 will be used. (For maintenence of
- XCPP only.)
- X.s.lm -16
- X.s
- X.i -8;PRE-DEFINED VARIABLES:
- X.s
- XWhen CPP begins processing, the following variables will
- Xhave been defined (unless the -N option is specified):
- X.s
- XTarget computer (as appropriate):
- X.s
- X.nf
- X pdp11, vax, M68000 m68000 m68k
- X.fill
- X.s
- XTarget operating system (as appropriate):
- X.s
- X.nf
- X rsx, rt11, vms, unix
- X.fill
- X.s
- XTarget compiler (as appropriate):
- X.s
- X.nf
- X decus, vax11c
- X.fill
- X.s
- XThe implementor may add definitions to this list.
- XThe default definitions match the definition of the
- Xhost computer, operating system, and C compiler.
- X.s
- XThe following are always available unless undefined (or
- X-N was specified twice):
- X.lm +16
- X.p -12
- X____FILE____ The input (or _#include) file being compiled
- X(as a quoted string).
- X.p -12
- X____LINE____ The line number being compiled.
- X.p -12
- X____DATE____ The date and time of compilation as
- Xa Unix ctime quoted string (the trailing newline is removed).
- XThus,
- X.s
- X.nf
- X printf("Bug at line _%s,", ____LINE____);
- X printf(" source file _%s", ____FILE____);
- X printf(" compiled on _%s", ____DATE____);
- X.fill
- X.s.lm -16
- X.s
- X.i -8;DRAFT PROPOSED ANSI STANDARD CONSIDERATIONS:
- X.s
- XThe current version of the Draft Proposed Standard
- Xexplicitly states that "readers are requested not to specify
- Xor claim conformance to this draft." Readers and users
- Xof Decus CPP should not assume that Decus CPP conforms
- Xto the standard, or that it will conform to the actual
- XC Language Standard.
- X.s
- XWhen CPP is itself compiled, many features of the Draft
- XProposed Standard that are incompatible with existing
- Xpreprocessors may be disabled. See the comments in CPP's
- Xsource for details.
- X.s
- XThe latest version of the Draft Proposed Standard (as reflected
- Xin Decus CPP) is dated November 12, 1984.
- X.s
- XComments are removed from the input text. The comment
- Xis replaced by a single space character. The -C option
- Xpreserves comments, writing them to the output file.
- X.s
- XThe '$' character is considered to be a letter. This is
- Xa permitted extension.
- X.s
- XThe following new features of C are processed by CPP:
- X.s.comment Note: significant spaces, not tabs, .br quotes #if, #elif
- X.br;####_#elif expression (_#else _#if)
- X.br;####'_\xNNN' (Hexadecimal constant)
- X.br;####'_\a' (Ascii BELL)
- X.br;####'_\v' (Ascii Vertical Tab)
- X.br;####_#if defined NAME 1 if defined, 0 if not
- X.br;####_#if defined (NAME) 1 if defined, 0 if not
- X.br;####_#if sizeof (basic type)
- X.br;####unary +
- X.br;####123U, 123LU Unsigned ints and longs.
- X.br;####12.3L Long double numbers
- X.br;####token_#token Token concatenation
- X.br;####_#include token Expands to filename
- X.s
- XThe Draft Proposed Standard has extended C, adding a constant
- Xstring concatenation operator, where
- X.s
- X.nf
- X "foo" "bar"
- X.s
- X.fill
- Xis regarded as the single string "foobar". (This does not
- Xaffect CPP's processing but does permit a limited form of
- Xmacro argument substitution into strings as will be discussed.)
- X.s
- XThe Standard Committee plans to add token concatenation
- Xto _#define command lines. One suggested implementation
- Xis as follows: the sequence "Token1_#Token2" is treated
- Xas if the programmer wrote "Token1Token2". This could
- Xbe used as follows:
- X.s
- X.nf
- X _#line 123
- X _#define ATLINE foo_#____LINE____
- X.s
- X.fill
- XATLINE would be defined as foo123.
- X.s
- XNote that "Token2" must either have the format of an
- Xidentifier or be a string of digits. Thus, the string
- X.s
- X.nf
- X _#define ATLINE foo_#1x3
- X.s
- X.fill
- Xgenerates two tokens: "foo1" and "x3".
- X.s
- XIf the tokens T1 and T2 are concatenated into T3,
- Xthis implementation operates as follows:
- X.s
- X.nf
- X 1. Expand T1 if it is a macro.
- X 2. Expand T2 if it is a macro.
- X 3. Join the tokens, forming T3.
- X 4. Expand T3 if it is a macro.
- X.s
- X.fill
- XA macro formal parameter will be substituted into a string
- Xor character constant if it is the only component of that
- Xconstant:
- X.s
- X.nf
- X _#define VECSIZE 123
- X _#define vprint(name, size) _\
- X printf("name" "[" "size" "] = {_\n")
- X ... vprint(vector, VECSIZE);
- X.s
- X.fill
- Xexpands (effectively) to
- X.s
- X.nf
- X vprint("vector[123] = {_\n");
- X.s
- X.fill
- XNote that this will be useful if your C compiler supports
- Xthe new string concatenation operation noted above.
- XAs implemented here, if you write
- X.s
- X.nf
- X _#define string(arg) "arg"
- X ... string("foo") ...
- X.s
- X.fill
- XThis implementation generates "foo", rather than the strictly
- Xcorrect ""foo"" (which will probably generate an error message).
- XThis is, strictly speaking, an error in CPP and may be removed
- Xfrom future releases.
- X.s
- X.i -8;ERROR MESSAGES:
- X.s
- XMany. CPP prints warning or error messages if you try to
- Xuse multiple-byte character constants (non-transportable)
- Xif you _#undef a symbol that was not defined, or if your
- Xprogram has potentially nested comments.
- X.s
- X.i -8;AUTHOR:
- X.s
- XMartin Minow
- X.s
- X.i -8;BUGS:
- X.s
- XThe _#if expression processor uses signed integers only.
- XI.e, _#if 0xFFFFu < 0 may be TRUE.
- X.s
- X.lm 8.rm 72.nhy
- X
- END_OF_FILE
- if test 8099 -ne `wc -c <'org/cpp.rno'`; then
- echo shar: \"'org/cpp.rno'\" unpacked with wrong size!
- fi
- # end of 'org/cpp.rno'
- fi
- if test -f 'org/make.boot' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'org/make.boot'\"
- else
- echo shar: Extracting \"'org/make.boot'\" \(579 characters\)
- sed "s/^X//" >'org/make.boot' <<'END_OF_FILE'
- X# Note: ccx is a cc frontend that knows about the preprocessor.
- X
- XCC = cc/ccx
- XCFLAGS = -DHOST=SYS_AMIGADOS -DOLD_PREPROCESSOR=1
- XOBJS = cpp1.o cpp2.o cpp3.o cpp4.o cpp5.o cpp6.o
- X
- Xncpp : $(OBJS)
- X $(CC) -o ncpp $(OBJS)
- X
- Xcpp1.o : cpp1.c cpp.h cppdef.h
- X $(CC) $(CFLAGS) -c cpp1.c
- X
- Xcpp2.o : cpp2.c cpp.h cppdef.h
- X $(CC) $(CFLAGS) -c cpp2.c
- X
- Xcpp3.o : cpp3.c cpp.h cppdef.h
- X $(CC) $(CFLAGS) -c cpp3.c
- X
- Xcpp4.o : cpp4.c cpp.h cppdef.h
- X $(CC) $(CFLAGS) -c cpp4.c
- X
- Xcpp5.o : cpp5.c cpp.h cppdef.h
- X $(CC) $(CFLAGS) -c cpp5.c
- X
- Xcpp6.o : cpp6.c cpp.h cppdef.h
- X $(CC) $(CFLAGS) -c cpp6.c
- END_OF_FILE
- if test 579 -ne `wc -c <'org/make.boot'`; then
- echo shar: \"'org/make.boot'\" unpacked with wrong size!
- fi
- # end of 'org/make.boot'
- fi
- if test -f 'org/makefile.txt' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'org/makefile.txt'\"
- else
- echo shar: Extracting \"'org/makefile.txt'\" \(3649 characters\)
- sed "s/^X//" >'org/makefile.txt' <<'END_OF_FILE'
- X# Unix makefile for cpp
- X#
- X# On certain systems, such as Unix System III, you may need to define
- X# $(LINTFLAGS) in the make command line to set system-specific lint flags.
- X#
- X# This Makefile assumes cpp will replace the "standard" preprocessor.
- X# Delete the reference to -DLINE_PREFIX=\"\" if cpp is used stand-alone.
- X# LINEFIX is a sed script filter that reinserts #line -- used for testing
- X# if LINE_PREFIX is set to "". Note that we must stand on our heads to
- X# match the # and a line had better not begin with $. By the way, what
- X# we really want is
- X# LINEFIX = | sed "s/^#/#line/"
- X#
- XCPPDEFINE = -DLINE_PREFIX=\"\"
- XLINEFIX = | sed "s/^[^ !\"%-~]/&line/"
- X#
- X# Define OLD_PREPROCESSOR non-zero to make a preprocessor which is
- X# "as compatible as possible" with the standard Unix V7 or Ultrix
- X# preprocessors. This is needed to rebuild 4.2bsd, for example, as
- X# the preprocessor is used to modify assembler code, rather than C.
- X# This is not recommended for current development. OLD_PREPROCESSOR
- X# forces the following definitions:
- X# OK_DOLLAR FALSE $ is not allowed in variables
- X# OK_CONCAT FALSE # cannot concatenate tokens
- X# COMMENT_INVISIBLE TRUE old-style comment concatenation
- X# STRING_FORMAL TRUE old-style string expansion
- X#
- XOLDDEFINE = -DOLD_PREPROCESSOR=1
- X#
- X# DEFINES collects all -D arguments for cc and lint:
- X# Change DEFINES = $(CPPDEFINE) $(OLDDEFINE)
- X# for an old-style preprocessor.
- X# If being used for GNU Emacs, the macro EMACS will be defined as -DEMACS.
- X#
- XDEFINES = $(CPPDEFINE) $(OLDDEFINE) $(EMACS)
- X
- XCFLAGS = -g $(DEFINES)
- X
- X#
- X# ** compile cpp
- X#
- XSRCS = cpp1.c cpp2.c cpp3.c cpp4.c cpp5.c cpp6.c
- XOBJS = cpp1.o cpp2.o cpp3.o cpp4.o cpp5.o cpp6.o
- Xcpp: $(OBJS)
- X $(CC) $(CFLAGS) $(OBJS) -o cpp
- X
- X#
- X# ** Test cpp by preprocessing itself, compiling the result,
- X# ** repeating the process and diff'ing the result. Note: this
- X# ** is not a good test of cpp, but a simple verification.
- X# ** The diff's should not report any changes.
- X# ** Note that a sed script may be executed for each compile
- X#
- Xtest:
- X cpp cpp1.c $(LINEFIX) >old.tmp1.c
- X cpp cpp2.c $(LINEFIX) >old.tmp2.c
- X cpp cpp3.c $(LINEFIX) >old.tmp3.c
- X cpp cpp4.c $(LINEFIX) >old.tmp4.c
- X cpp cpp5.c $(LINEFIX) >old.tmp5.c
- X cpp cpp6.c $(LINEFIX) >old.tmp6.c
- X $(CC) $(CFLAGS) old.tmp[123456].c
- X a.out cpp1.c >new.tmp1.c
- X a.out cpp2.c >new.tmp2.c
- X a.out cpp3.c >new.tmp3.c
- X a.out cpp4.c >new.tmp4.c
- X a.out cpp5.c >new.tmp5.c
- X a.out cpp6.c >new.tmp6.c
- X diff old.tmp1.c new.tmp1.c
- X diff old.tmp2.c new.tmp2.c
- X diff old.tmp3.c new.tmp3.c
- X diff old.tmp4.c new.tmp4.c
- X diff old.tmp5.c new.tmp5.c
- X diff old.tmp6.c new.tmp6.c
- X rm a.out old.tmp[123456].* new.tmp[123456].*
- X
- X#
- X# A somewhat more extensive test is provided by the "clock"
- X# program (which is not distributed). Substitute your favorite
- X# macro-rich program here.
- X#
- Xclock: clock.c cpp
- X cpp clock.c $(LINEFIX) >temp.cpp.c
- X cc temp.cpp.c -lcurses -ltermcap -o clock
- X rm temp.cpp.c
- X
- X#
- X# ** Lint the code
- X#
- X
- Xlint: $(SRCS)
- X lint $(LINTFLAGS) $(DEFINES) $(SRCS)
- X
- X#
- X# ** Remove unneeded files
- X#
- Xclean:
- X rm -f $(OBJS) cpp
- X
- X#
- X# ** Rebuild the archive files needed to distribute cpp
- X# ** Uses the Decus C archive utility.
- X#
- X
- Xarchc: archc.c
- X $(CC) $(CFLAGS) archc.c -o archc
- X
- Xarchx: archx.c
- X $(CC) $(CFLAGS) archx.c -o archx
- X
- Xarchive: archc
- X archc readme.txt cpp.mem archx.c archc.c cpp.rno makefile.txt \
- X cpp*.h >cpp1.arc
- X archc cpp1.c cpp2.c cpp3.c >cpp2.arc
- X archc cpp4.c cpp5.c cpp6.c >cpp3.arc
- X
- X#
- X# Object module dependencies
- X#
- X
- Xcpp1.o : cpp1.c cpp.h cppdef.h
- X
- Xcpp2.o : cpp2.c cpp.h cppdef.h
- X
- Xcpp3.o : cpp3.c cpp.h cppdef.h
- X
- Xcpp4.o : cpp4.c cpp.h cppdef.h
- X
- Xcpp5.o : cpp5.c cpp.h cppdef.h
- X
- Xcpp6.o : cpp6.c cpp.h cppdef.h
- X
- X
- END_OF_FILE
- if test 3649 -ne `wc -c <'org/makefile.txt'`; then
- echo shar: \"'org/makefile.txt'\" unpacked with wrong size!
- fi
- # end of 'org/makefile.txt'
- fi
- if test -f 'org/readme' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'org/readme'\"
- else
- echo shar: Extracting \"'org/readme'\" \(1025 characters\)
- sed "s/^X//" >'org/readme' <<'END_OF_FILE'
- XThis is a version of the Decus cpp which has been modified to run on
- Xthe Amiga. The bootstraping and porting process is not real straight-
- Xforward, and in fact required the resources of a Unix system cpp since
- Xneither Manx nor Lattice could properly deal with the cpp source code
- Xbefore preprocessing. Thus, it may require some work and ingenuity
- Xto recreate the supplied executable!
- X
- XThis cpp predefines "amiga" as opposed to "AMIGA". This is a somewhat
- Xbelated attempt to coerce the Amiga world into following the convention
- Xof other C environments that the system predefines are lowercase to avoid
- Xclashes with user predefines, which are uppercase by convention.
- X
- XA hacked up version of my Unix like cc frontend that knows about the
- Xcpp is also supplied, for the Manx compiler.
- X
- XI was holding this back until I had a copy of the public domain C
- Xcompiler and assembler to go along with it, but since these two items
- Xappear to be unreleasable for the immediate future, decided to go ahead
- Xand release the cpp now.
- X
- X-Fred
- END_OF_FILE
- if test 1025 -ne `wc -c <'org/readme'`; then
- echo shar: \"'org/readme'\" unpacked with wrong size!
- fi
- # end of 'org/readme'
- fi
- if test -f 'org/readme.txt' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'org/readme.txt'\"
- else
- echo shar: Extracting \"'org/readme.txt'\" \(4421 characters\)
- sed "s/^X//" >'org/readme.txt' <<'END_OF_FILE'
- X
- XDecus cpp is a public-domain implementation of the C preprocessor.
- XIt runs on VMS native (Vax C), VMS compatibilty mode (Decus C),
- XRSX-11M, RSTS/E, P/OS, and RT11, as well as on several varieties
- Xof Unix, including Ultrix. Decus cpp attempts to implement features
- Xin the Draft ANSI Standard for the C language. It should be noted,
- Xhowever, that this standard is under active development: the current
- Xdraft of the standard explicitly states that "readers are requested
- Xnot to specify or claim conformance to this draft." Thus readers
- Xand users of Decus cpp should not assume that it conforms to the
- Xdraft standard, or that it will conform to the actual C language
- Xstandard.
- X
- XThese notes describe how to extract the cpp source files, configure it
- Xfor your needs, and mention a few design decisions that may be of interest
- Xto maintainers.
- X
- X Installation
- X
- XBecause the primary development of cpp was not on Unix, it
- Xis distributed using the Decus C archive program (quite similar
- Xto the archiver published in Kernighan and Plauger's Software
- XTools). To extract the files from the net.sources distribution,
- Xsave this message as cpp1.arc and the other two distribution
- Xfiles as cpp2.arc and cpp3.arc. Then, using your favorite editor,
- Xlocate the archx.c program, just following the line beginning with
- X"-h- archx.c" -- the format of the distribution is just:
- X
- X -h- readme.txt
- X ... this file
- X -h- cpp.mem
- X ... description of cpp
- X -h- archx.c
- X ... archx.c program -- extracts archives
- X -h- archc.c
- X ... archc.c program -- creates archives
- X
- XCompile archx.c -- it shouldn't require any special editing.
- XThen run it as follows:
- X
- X archx *.arc
- X
- XYou do not need to remove mail headers from the saved messages.
- X
- XYou should then read through cppdef.h to make sure the HOST and
- XTARGET (and other implementation-specific) definitions are set
- Xcorrectly for your machine, editing them as needed.
- X
- XYou may then copy makefile.txt to Makefile, editing it as needed
- Xfor your particular system. On Unix, cpp should be compiled
- Xby make without further difficulty. On other operating systems,
- Xyou should compile the six source modules, linking them together.
- XNote that, on Decus C based systems, you must extend the default
- Xstack allocation. The Decus C build utility will create the
- Xappropriate command file.
- X
- X Support Notes
- X
- XThe USENET distribution kit was designed to keep all submissions around
- X50,000 bytes:
- X
- Xcpp1.arc:
- X readme.txt This file
- X cpp.mem Documentation page (see below)
- X archx.c Archive extraction program
- X archc.c Archive construction program
- X cpp.rno Source for cpp.mem (see below)
- X makefile.txt Unix makefile -- copy to Makefile
- X cpp.h Main header file (structure def's and globals)
- X cppdef.h Configuration file (host and target definitions)
- X
- Xcpp2.arc:
- X cpp1.c Mainline code, documentation master sources
- X cpp2.c most #control processing
- X cpp3.c filename stuff and command line parsing
- Xcpp3.arc:
- X cpp4.c #define processor
- X cpp5.c #if <expr> processor
- X cpp6.c Support code (symbol table and I/O routines)
- X
- XCpp intentionally does not rely on the presence of a full-scale
- Xmacro preprocessor, it does require the simple parameter substitution
- Xpreprocessor capabilities of Unix V6 and Decus C. If your C
- Xlanguage lacks full preprocessing, you should make sure "nomacargs"
- Xis #define'd in cpp.h. (This is done automatically by the Decus C
- Xcompiler.)
- X
- XThe documentation (manual page) for cpp is included as cpp.mem
- Xand cpp.rno. Cpp.rno is in Dec Runoff format, built by a Decus C
- Xutility (getrno) from original source which is embedded in cpp1.c.
- XTo my knowledge, there is no equivalent program that creates
- Xthe nroff source appropriate for Unix.
- X
- XI would be happy to receive fixes to any problems you encounter.
- XAs I do not maintain distribution kit base-levels, bare-bones
- Xdiff listings without sufficient context are not very useful.
- XIt is unlikely that I can find time to help you with other
- Xdifficulties.
- X
- X Acknowledgements
- X
- XI received a great deal of help from many people in debugging cpp.
- XAlan Feuer and Sam Kendall used "state of the art" run-time code
- Xcheckers to locate several errors. Ed Keiser found problems when
- Xcpp was used on machines with different int and pointer sizes.
- XDave Conroy helped with the initial debugging, while Arthur Olsen
- Xand George Rosenberg found (and solved) several problems in the
- Xfirst USENET release.
- X
- XMartin Minow
- Xdecvax!minow
- X
- END_OF_FILE
- if test 4421 -ne `wc -c <'org/readme.txt'`; then
- echo shar: \"'org/readme.txt'\" unpacked with wrong size!
- fi
- # end of 'org/readme.txt'
- fi
- if test -f 'test.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'test.c'\"
- else
- echo shar: Extracting \"'test.c'\" \(328 characters\)
- sed "s/^X//" >'test.c' <<'END_OF_FILE'
- X#define cat(x, y) x ## y
- X#define var123 Werkt!!!
- Xcat(var, 123);
- Xcat(cat(1, 2), 3);
- X#define cat2(x, y) x/**/y
- Xcat2(var, 123);
- Xcat2(cat2(1, 2), 3);
- X#define str(arg) #arg
- Xstr("Hallo");
- Xstr(Ha"l"lo);
- X#define instr(x) "x y" "x"
- Xinstr(Dit is de tweede string)
- X#define spaces a b c \
- X nexy line
- X#define zeroargs()
- END_OF_FILE
- if test 328 -ne `wc -c <'test.c'`; then
- echo shar: \"'test.c'\" unpacked with wrong size!
- fi
- # end of 'test.c'
- fi
- echo shar: End of archive 1 \(of 5\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 4 5 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 5 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Submissions to comp.sources.amiga and comp.binaries.amiga should be sent to:
- amiga@cs.odu.edu
- or amiga@xanth.cs.odu.edu ( obsolescent mailers may need this address )
- or ...!uunet!xanth!amiga ( very obsolescent mailers need this address )
-
- Comments, questions, and suggestions s should be addressed to ``amiga-request''
- (only use ``amiga'' for submissions) at the above addresses.
-